package org.dzq.designmode.proxy.dynamicproxy;

import java.lang.reflect.Proxy;

/**
 * @ClassName: AnimalProxyFactory
 * @Package: org.dzq.designmode.proxy.dynamicproxy
 * @author: 越
 * @date: 2023/6/17 12:40
 * @Description:
 */
public class ProxyFactory {

    @SuppressWarnings("unchecked")
    public static <T> T getProxyObject(Class<?> clazz,T concreteProxyObject){
        InvocationHandlerImpl invocationHandlerImpl = new InvocationHandlerImpl(concreteProxyObject);
        T proxyObject = (T)Proxy.newProxyInstance(clazz.getClassLoader(),new Class[]{clazz},invocationHandlerImpl);
        return proxyObject;
    }
}
